package com.openbravo.data.gui;

import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;

import com.openbravo.data.user.I_BrowsableTreeEditableData;

import cn.ekuma.data.dao.bean.I_ViewBean;
import cn.ekuma.data.ui.swing.dnd.BeanTransferable;

public class JDragAbleTreeNavigator<T> extends JTreeNavigator implements
DragGestureListener, // For recognizing the start of drags
DragSourceListener{

	
	public JDragAbleTreeNavigator(I_BrowsableTreeEditableData bd) {
		super(bd);
		DragSource dragSource = DragSource.getDefaultDragSource();
	    dragSource.createDefaultDragGestureRecognizer(m_jTree,
	        DnDConstants.ACTION_COPY_OR_MOVE, this);
	}

	@Override
	public void dragEnter(DragSourceDragEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragOver(DragSourceDragEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dropActionChanged(DragSourceDragEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragExit(DragSourceEvent dse) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragDropEnd(DragSourceDropEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragGestureRecognized(DragGestureEvent dge) {
		T obj=(T) m_bd.getSelectedObj().getCategory();
	    Transferable transferable = null;
	    transferable=new BeanTransferable((I_ViewBean) obj); 
	    dge.startDrag(null, transferable, this);
	}
}
